<?php
    require('./Utils.php');

    if(is_get()){
        getJson(500, '不支持get请求', null);
        return;
    }

    $post = getJsonParamter();

    $username = $post['username'];
    $password = $post['password'];
    $payment = $post['payPassword'];
    $phone = $post['phoneNumber'];

    $conn = getConnection();
    $sql = "INSERT INTO user(username, password, payment, phone, avatar) VALUES(?, ?, ?, ?, 'upload/default_avatar.jpg')";

    $result = execute($conn, $sql, $username, $password, $payment, $phone);

    if($result){
       getJson(200, '注册成功', null);
    }else{
       getJson(500, '注册失败', null);
    }

?>
